home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1UQGD2V (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  3.6 KB  |  99 lines

  1. package com.sun.java.swing;
  2.  
  3. import com.sun.java.accessibility.Accessible;
  4. import com.sun.java.accessibility.AccessibleContext;
  5. import com.sun.java.swing.plaf.CheckBoxMenuItemUI;
  6. import java.awt.Component;
  7. import java.awt.Container;
  8.  
  9. public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants, Accessible {
  10.    public JCheckBoxMenuItem() {
  11.       this((String)null, (Icon)null);
  12.    }
  13.  
  14.    public JCheckBoxMenuItem(Icon icon) {
  15.       this((String)null, icon);
  16.    }
  17.  
  18.    public JCheckBoxMenuItem(String text) {
  19.       this(text, (Icon)null);
  20.    }
  21.  
  22.    public JCheckBoxMenuItem(String text, Icon icon) {
  23.       ((AbstractButton)this).setModel(new JToggleButton.ToggleButtonModel());
  24.       this.init(text, icon);
  25.       ((AbstractButton)this).setBorderPainted(false);
  26.       ((AbstractButton)this).setFocusPainted(false);
  27.       ((AbstractButton)this).setHorizontalTextPosition(4);
  28.       ((AbstractButton)this).setHorizontalAlignment(2);
  29.       this.updateUI();
  30.    }
  31.  
  32.    public JCheckBoxMenuItem(String text, Icon icon, boolean b) {
  33.       this(text, icon);
  34.       ((AbstractButton)this).setSelected(b);
  35.    }
  36.  
  37.    public JCheckBoxMenuItem(String text, boolean b) {
  38.       this(text);
  39.       ((AbstractButton)this).setSelected(b);
  40.    }
  41.  
  42.    public AccessibleContext getAccessibleContext() {
  43.       if (super.accessibleContext == null) {
  44.          super.accessibleContext = new AccessibleJCheckBoxMenuItem(this);
  45.       }
  46.  
  47.       return super.accessibleContext;
  48.    }
  49.  
  50.    public synchronized Object[] getSelectedObjects() {
  51.       if (!((AbstractButton)this).isSelected()) {
  52.          return null;
  53.       } else {
  54.          Object[] selectedObjects = new Object[1];
  55.          selectedObjects[0] = ((AbstractButton)this).getText();
  56.          return selectedObjects;
  57.       }
  58.    }
  59.  
  60.    public boolean getState() {
  61.       return ((AbstractButton)this).isSelected();
  62.    }
  63.  
  64.    public String getUIClassID() {
  65.       return "CheckBoxMenuItemUI";
  66.    }
  67.  
  68.    protected void init(String text, Icon icon) {
  69.       ((Container)this).setLayout(new OverlayLayout(this));
  70.       if (text != null) {
  71.          ((AbstractButton)this).setText(text);
  72.          if (icon != null) {
  73.             ((AbstractButton)this).setVerticalTextPosition(3);
  74.          }
  75.       }
  76.  
  77.       if (icon != null) {
  78.          ((AbstractButton)this).setIcon(icon);
  79.       }
  80.  
  81.       ((Component)this).addFocusListener(new 1(this));
  82.    }
  83.  
  84.    public void requestFocus() {
  85.    }
  86.  
  87.    public synchronized void setState(boolean b) {
  88.       ((AbstractButton)this).setSelected(b);
  89.    }
  90.  
  91.    public void setUI(CheckBoxMenuItemUI ui) {
  92.       super.setUI(ui);
  93.    }
  94.  
  95.    public void updateUI() {
  96.       this.setUI((CheckBoxMenuItemUI)UIManager.getUI(this));
  97.    }
  98. }
  99.